TEventArgs
CSharpTest.Net
EventHandlerForControl<TEventArgs> Class
Members  Example  See Also  Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Delegates Namespace : EventHandlerForControl<TEventArgs> Class

Glossary Item Box

Provies a wrapper type around event handlers for a control that are safe to be used from events on another thread. If the control is not valid at the time the delegate is called an exception of type ObjectDisposedExcpetion will be raised.

Syntax

Visual Basic (Declaration) 
Public Class EventHandlerForControl(Of TEventArgs As EventArgs) 
C# 
public class EventHandlerForControl<TEventArgs> 
where TEventArgs: EventArgs

Type Parameters

TEventArgs

Example

Library/Library.Test/TestDelegates.cs

C#Copy Code
EventHandler<VerifiedReceiptEventArgs> handler;
VerifiedReceiptEventArgs args = new VerifiedReceiptEventArgs();

_thread.Start();
_form.FormCreated.WaitOne();

try
{
    handler = new EventHandlerForControl<VerifiedReceiptEventArgs>(_form, CloseTheForm);
    handler(null, args);
}
finally
{
    _thread.Join();
}
VB.NETCopy Code
Dim handler As EventHandler(Of VerifiedReceiptEventArgs)
Dim args As New VerifiedReceiptEventArgs()

_thread.Start()
_form.FormCreated.WaitOne()

Try
    handler = New EventHandlerForControl(Of VerifiedReceiptEventArgs)(_form, CloseTheForm)
    handler(Nothing, args)
Finally
    _thread.Join()
End Try

Inheritance Hierarchy

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys